home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / ASCFIL.ZIP / TABLE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-01  |  2.0 KB  |  95 lines

  1. //*                             Table.H
  2. //*
  3. //*           Header File for the Table.cpp Functions Class
  4. //*
  5. //*
  6. //***************************************************************************
  7.  
  8.  
  9. #ifndef TABLE_H
  10. #define TABLE_H
  11.  
  12. #include "record.h"
  13.  
  14. #define TBL_OK                  0
  15. #define TBL_EMPTY         1
  16. #define TBL_BEGIN         2
  17. #define TBL_END                 3
  18. #define TBL_RANGE               4
  19. #define TBL_NOTFOUND            5
  20.  
  21. //-------------------------------------------------------------------------
  22. class IndexTable {
  23. private:
  24.         int     handle;
  25.         int     keySize;
  26.     long    keyCount;
  27.     long    current;
  28.     char    *Key;
  29.  
  30.         struct KeyData
  31.         {
  32.         long    recnum;
  33.         long    parent;
  34.         long    left;
  35.         long    right;
  36.         char    loc;
  37.         }keyData;
  38.  
  39. public:
  40.  
  41.     IndexTable(char *name, int keysize);
  42.     ~IndexTable(void);
  43.     
  44.     void    addKey(char *key, long recnum);
  45.  
  46.     long    findKey(char *key);
  47.     long    getFirst(long start=0);
  48.     long    getLast(long start=0);
  49.     long    getNext(void);
  50.     long    getPrev(void);
  51. };
  52.  
  53. //-------------------------------------------------------------------------
  54. class Table {
  55.  
  56. private:
  57.     static int usage;
  58.         static IndexTable*     pIndex[10];
  59.         static Table*          pTable[10];
  60.  
  61.         Record                 *pRecord;
  62.  
  63.         int             hFile;
  64.     long        cursor;
  65.     long        fileSize;
  66.     long        recCount;
  67.         int             recLength;
  68.         int             keySize;
  69.  
  70.     char*        indexName(int handle);
  71.  
  72. public:
  73.     Table(char *file, Record *record);
  74.     ~Table(void);
  75.  
  76.     int openIndex(int *fields, int fcount);
  77.     int closeIndex(int ix);
  78.             
  79.     int Get(void);
  80.     int Search(char *fldName, char *search);
  81.     int Search(int fldNum, char *search);
  82.     int Search(char *key, int ihandle);
  83.  
  84.     int gotoFirst(int ihandle=-1);
  85.     int gotoLast(int ihandle=-1);
  86.     int gotoNext(int ihandle=-1);
  87.     int gotoPrev(int ihandle=-1);
  88.     int gotoRecNum(long recnum);
  89.  
  90.         long getRecNum(void)                             {return(cursor);};
  91.     long getRecCount(void)                 {return(recCount);};
  92. };
  93.  
  94. #endif
  95.